package com.example.kx005_rabbit;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.view.View;

/**
 * dog 视图
 */
public class DogView extends View {
    // x,y 坐标
    public float x;
    public float y;

    public DogView(Context context) {
        super(context);
        x = 290;
        y = 130;

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        //画笔
        Paint paint = new Paint();
        //载入图片
        Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(), R.mipmap.img01);
        Bitmap bitmap2 = BitmapFactory.decodeResource(this.getResources(), R.mipmap.img02);
        Bitmap bitmap3 = BitmapFactory.decodeResource(this.getResources(), R.mipmap.img03);

        canvas.drawBitmap(bitmap,x,y,paint);
        canvas.drawBitmap(bitmap2,x+bitmap2.getWidth(),y+bitmap2.getHeight(),paint);
        canvas.drawBitmap(bitmap3,x-bitmap3.getWidth(),y-bitmap3.getHeight(),paint);

        if (bitmap.isRecycled()){
            bitmap.recycle();
        }


        if (bitmap2.isRecycled()){
            bitmap2.recycle();
        }


        if (bitmap3.isRecycled()){
            bitmap3.recycle();
        }



    }
}
